using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeObj : MonoBehaviour
{
    public GameObject breakEff;
    public GameObject[] rewardObj;
    private void OnTriggerEnter(Collider other)
    {
        int rdInt = Random.Range(0, 100);
        if (rdInt < 98)
        {
            rdInt = Random.Range(0,rewardObj.Length);
            Instantiate(rewardObj[rdInt],transform.position,transform.rotation);
        }
        GameObject eff = Instantiate(breakEff, transform.position, transform.rotation);
        AudioSource audioSource = eff.GetComponent<AudioSource>();
        audioSource.volume = GameDataMgr.Instance.musicData.soundValue;
        audioSource.mute = !GameDataMgr.Instance.musicData.isOpenBK;
        Destroy(eff, 2);

        Destroy(gameObject);
    }
}
